package com.dcbeida.model;

import com.dcbeida.MyApplication;
import com.dcbeida.utils.GenApiHashUrl;
import com.dcbeida.utils.JsonGet;

import dc.medicine.com.okhttplib.OkHttpUtils;
import dc.medicine.com.okhttplib.callback.AbsCallback;

/**
 * Sean
 */
public class SourceModel {

    private static SourceModel mSourceModel;

    private SourceModel() {

    }

    public static SourceModel newInstance() {
        if (mSourceModel == null) {
            return new SourceModel();
        } else {
            return mSourceModel;
        }
    }

    public void getSourceList(AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "getproviderlist")
                .paramsApp("params", new JsonGet().putopt("uid", MyApplication.user.getUid()).tostring()).execute(mAbsCallback);
    }

    public void getSourcelInfo(String keyword, AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "queryprovider")
                .paramsApp("params", new JsonGet().putopt("uid", MyApplication.user.getUid()).putopt("keyword", keyword).tostring()).execute(mAbsCallback);
    }

    public void getCancel() {
        OkHttpUtils.getInstance().cancelTag(this);
    }
}
